package com.itheima.dianming;

import cn.hutool.core.lang.Snowflake;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@MapperScan(basePackages = "com.itheima.dianming.mapper")
@EnableAspectJAutoProxy
@EnableCaching
@EnableTransactionManagement
public class DianmingApplication {
    public static void main(String[] args) {
        SpringApplication.run(DianmingApplication.class, args);
    }

    @Bean
    public Snowflake getSnowflake(){
        return new Snowflake(1,1);
    }

    @Bean
    public RedisTemplate getRedisTemplate(RedisTemplate redisTemplate){
        redisTemplate.setKeySerializer(new StringRedisSerializer());
        return redisTemplate;
    }

    @Bean
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }
}
